<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>trm</title>
<style>
*{
    margin: 0;
    padding: 0;
}
.title {
    display: none;
    color: yellow;
    font-size: 30px;
    text-align: center;
}
body {
    //height: 100%;
    background: url(img/login.jpg);
}
.login {
    //margin-top: 20%;
    //background: red;
    padding: 50px 0;
}
.main {
    width:300px;
    margin:0 auto;
}
.input{
    width: 100%;
    height: 30px;
    font-size: 20px;
    border: 0;
    border-left: 1px solid #9AC0CD;
    position: relative;
    top: -29px;
}
.input1{
    width: 100%;
    height: 35px;
    font-size: 20px;
    line-height: 35px;
    background: #D1EEEE;
    margin-top: 30px;
    cursor: pointer;
    text-align: center;
}
.input1:hover {
    background: #CFCFCF;
}
.in {
    margin-top: 30px;
    width: 100%;
    height: 32px;
    box-sizing:border-box;
    padding-left: 35px;
    padding-right: 2px;
    background: #fff;
}
.in img {
    position: relative;
    left: -32px;
    top: 2px;
    width: 30px;
    height: 30px;
}
.text {
    color: white;
}
</style>
<script type="text/javascript" src="/trm/javascript/jquery-3.2.1.js"></script>
<script type="text/javascript" src="/trm/javascript/window/openwindow.js"></script>
<script type="text/javascript">
function submit() {
	document.activeElement.blur();
	if (document.getElementById("account").value == "") {
  		mmy_alert("账号不能为空！");
  		return false;
	}
	if (document.getElementById("password").value == "") {
        mmy_alert("密码不能为空！");
        return false;
    }
	$.ajax({  
        cache: true,  
        type: "POST",  
        url:"LoginServlet",  
        data:$('#form').serialize(),// 你的formid  
        async: false,  
        error: function(request) {  
            alert("Connection error:"+request.error);  
        },  
        success: function(data) {  
            var result = eval('(' + data + ')');
            if (result.result == "success") {
            	window.location.href = result.url;
            }
            if (result.result == "error") {
            	mmy_alert("用户名或密码错误！");
            }
        }  
    }); 
	//document.getElementById("form").submit();
}
</script>
</head>
<body>
	<div class="login">
	  <div class="title">trm</div>
	  <div class="main">
		<form id="form" action="LoginServlet">
		  <input type="hidden" name="action" value="login"/>
		  <div class="in">
		      <!-- <a class="text">账号：</a> -->
		      <img src="img/user.png"/>
		      <input id="account" class="input" type="text" name="account"/>
		  </div>
		  <div class="in">
			  <!-- <a class="text">密码：</a> -->
			  <img src="img/password.png"/>
			  <input id="password" class="input" type="password" name="password"/>
		  </div>
		  <div><div class="input1" onclick="submit()">登录</div></div>
		</form>
	  </div>
	</div>
</body>
</html>